class Solution {
    public String longestCommonPrefix(String[] strs) {
        if(strs[0]=="") return "";
        int n=strs[0].length();
        char[] tmp=strs[0].toCharArray();
        int count=10000;
        for(String str:strs){
            int nn=0;

            char[] arr=str.toCharArray();
            for(int i=0;i<n;i++){
                if(i<arr.length&&arr[i]==tmp[i]){
                    nn++;
                }else break;
            }


            count=Math.min(count,nn);


        }

        return strs[0].substring(0,count);

    }
}